//
//  SetVC_SecondFloor.m
//  Login
//
//  Created by mac on 17/2/23.
//  Copyright © 2017年 ZF. All rights reserved.
//

#import "SetVC_SecondFloor.h"
#import "UserCell.h"
#import "GlobalCell.h"
#import "LoginVC.h"
#import "SetVC_setUser.h"
#import "Helps.h"


@interface SetVC_SecondFloor ()
{
    NSArray *data;
    NSArray *imgarr;
    NSString *username;
    
}
@end

@implementation SetVC_SecondFloor

- (void)viewWillAppear:(BOOL)animated
{
    AppDelegate *delegate = [Helps app];
    username = @"用户名:";
    username = [username stringByAppendingString:delegate.userName];
    [self.tableView reloadData];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    data = @[@"设置帐号"];
    imgarr = @[@"修改用户"];
    self.tableView.scrollEnabled = NO;
    self.tableView.separatorStyle =  UITableViewCellSeparatorStyleNone;
   
    

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(section == 1)
    {
        return data.count;
    }
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = COLOR(215, 215, 215, 1);
    
    if(indexPath.section == 0)
    {
        UserCell *cell = [tableView dequeueReusableCellWithIdentifier:@"usercell" forIndexPath:indexPath];
        cell.label.text = username;
        view.frame = CGRectMake(0, 79, tableView.frame.size.width, 1);
        [cell addSubview:view];
        return cell;
    }
    
        GlobalCell *cell = [tableView dequeueReusableCellWithIdentifier:@"global" forIndexPath:indexPath];
        
        if(indexPath.row == 0)
        {
            cell.imgVIew.image = [UIImage imageNamed:imgarr[indexPath.row]];
            cell.label.text = data[indexPath.row];
            view.frame = CGRectMake(0, 43, tableView.frame.size.width, 1);
            [cell addSubview:view];
        }
        return cell;
   
}


- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)];
    view.backgroundColor = COLOR(230, 230, 230, 1);
    return view;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)];
    view.backgroundColor = COLOR(230, 230, 230, 1);
    return view;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if(section == 0)
    {
        return 0;
    }
    return 20;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.section == 0)
    {
        return 80;
    }
    return 44;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.section == 1)
    {
        if(indexPath.row == 0)
        {
            SetVC_setUser *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"setUser"];
            [self.navigationController pushViewController:vc animated:YES];
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
